﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using Core.GenericDefinitions.BaseClasses;

namespace UI.UserControls
{
    public partial class MFAVerticalTabPage : UserControl, INotifyPropertyChanged
    { 

        #region TabHeight VM Property
        private double? _TabHeight;
        public double TabHeight
        {
            get
            {
                //if (ViewModelBase.IsInDesignModeStatic)
                //{
                //    return 40;
                //}
                return _TabHeight ?? 10.0;
            }
            set
            {
                if (_TabHeight == value) return;
                _TabHeight = value;
                RaisePropertyChanged("TabHeight");
            }
        }
        #endregion TabHeight

        #region TabHeader VM Property
        private string _TabHeader;
        public string TabHeader
        {
            get
            {
                return _TabHeader;
            }
            set
            {
                if (_TabHeader == value) return;
                _TabHeader = value;
                RaisePropertyChanged("TabHeader");
            }
        }
        #endregion TabHeader

        #region TabColor VM Property
        private Brush _TabColor;
        public Brush TabColor
        {
            get
            {
                //if (ViewModelBase.IsInDesignModeStatic)
                //{
                //    return new SolidColorBrush(Colors.Blue);
                //}
                return _TabColor;
            }
            set
            {
                if (_TabColor == value) return;
                _TabColor = value;
                RaisePropertyChanged("TabColor");
            }
        }
        #endregion TabColor


        public MFAVerticalTabPage()
        {
            InitializeComponent();
        }


        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }


        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        private void userControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            int zindex = 0;
            Grid gr = (Grid)this.Parent;
            foreach (UIElement item in gr.Children)
            {
                zindex = (zindex > Canvas.GetZIndex(item)) ? zindex : Canvas.GetZIndex(item);
            }
            this.SetValue(Canvas.ZIndexProperty, zindex + 1);
        }



        #region Content (DependencyProperty)
        public FrameworkElement Content
        { 
            get { return (FrameworkElement)GetValue(SetContentProperty); }
            set { SetValue(SetContentProperty, value); }
        }
        public static readonly DependencyProperty SetContentProperty =
        DependencyProperty.Register("Content", typeof(FrameworkElement), typeof(MFAVerticalTabPage),
        new PropertyMetadata(null, new PropertyChangedCallback(OnSetContentChanged)));
        private static void OnSetContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((MFAVerticalTabPage)d).OnSetContentChanged(e);
        }
        protected virtual void OnSetContentChanged(DependencyPropertyChangedEventArgs e)
        {
            if (Content != null)
                this.TabContent.Content = Content;
        }
        #endregion


    }
}
